﻿using System.Web.UI.WebControls;

namespace Inkubator.Wizard.WizardGenerator.Validator
{
    public abstract class WizardValidatorFactory
    {

        public enum ValidatorType
        {
            Required, Range, RegularExpression, Compare
        }

        /// <summary>
        /// This method return a Validation component based on the argument received.
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static BaseValidator validatorFactory(ValidatorType type, Validation validation)
        {
            switch (type)
            {
                case ValidatorType.Required:
                    return new RequiredFieldValidator();
                case ValidatorType.Range:
                    RangeValidator range = new RangeValidator();
                    string[] attributes = validation.getAttributes();
                    range.MinimumValue = attributes[0];
                    range.MaximumValue = attributes[1];
                    return range;
            }

            throw new System.NotSupportedException("Not Valid Type");
        }

    }
}
